package com.alibaba.config;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;

/**
 * @Author: zhuangzhiwen
 * @Date: 2021/8/18
 */

public class AopAround {
    public Object around(ProceedingJoinPoint joinPoint){
        try {
            System.out.println("前置增强");
            //环绕增强 必须调用原始方法
            Object result = joinPoint.proceed(joinPoint.getArgs());
            System.out.println("后置增强");
            return result;
        } catch (Throwable throwable) {
            System.out.println("异常增强");
            throwable.printStackTrace();
        } finally {
            System.out.println("最终增强");
        }
        return null;
    }
}
